import request from '@/utils/request'

/**
 * 获取活动报名信息
 * @param {Object} registrationId - 活动注册的 ID
 * @returns {Promise<Object>} - 返回包含活动注册信息的 Promise
 */
// 获取活动报名信息
export const getRegistrationDetailService = (registrationId) => {
  return request.get(`/event-registrations/${registrationId}`);
}
/**
 * 提交活动报名信息
 * @param {Object} registrationInfo - 包含报名信息的对象， * 
 * @returns {Promise<Object>} - 返回包含提交结果的 Promise
 */
// 提交活动报名
export const submitRegistrationService = (registrationInfo) => {
  return request.post('/event-registrations', registrationInfo);
}

/**
 * 取消活动报名
 * @param {string} registrationId - 活动报名的 ID
 * @returns {Promise<Object>} - 返回包含取消结果的 Promise
 */
// 取消活动报名
export const cancelRegistrationService = (registrationId) => {
  return request.delete(`/event-registrations/${registrationId}`);
}

/**
 * 获取活动的报名记录
 * @param {string} eventId - 活动的 ID
 * @param {Object} params - 分页参数，包含 page 和 pageSize
 * @returns {Promise<Object>} - 返回包含活动注册记录的 Promise
 */
// 获取当前活动的报名记录
export const getThisEventRegistrationRecordsService = (eventId, params) => {
  return request.get(`/event-registrations/event/${eventId}/attendees`, {
    params: {
      page: params.page,
      pageSize: params.pageSize
    }
  });
}
// GET http://localhost:8081/api/v1/event-registrations/event/200/attendees?page=1&pageSize=15

// http://localhost:8081/api/v1/event-registrations/myRegistrations?page=3&pageSize=15
// 获取我的活动报名记录
export const getMyRegistrationRecordsService = (params) => {
  return request.get(`/event-registrations/myRegistrations`, { params:{
    page: params.page,
    pageSize: params.pageSize
  } })
}

// DELETE http://localhost:8081/api/v1/event-registrations/{{registrationId}}
// 取消活动报名
export const deleteRegistrationService = (registrationId) => {
  return request.delete(`/event-registrations/${registrationId}`);
}